package com.cn.kabalifeuser.ui.login;

import com.cn.kabalifeuser.api.Api;
import com.cn.kabalifeuser.base.BasePresenter;
import com.cn.kabalifeuser.callback.CacheCallBack;
import com.cn.kabalifeuser.config.Constants;
import com.cn.kabalifeuser.ui.login.bean.AgreementBean;
import com.cn.kabalifeuser.ui.my.bean.MyUserInfoBean;
import com.cn.kabalifeuser.utils.LoggerUtils;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;

/**
 * Created by 晓林 on 2020/10/15.
 * function:
 */
public class AgreementPresenter extends BasePresenter<AgreementView> {

    public void onAgreementData(int type) {
        OkGo.<AgreementBean>get(Api.API_LOGIN_AGR)
                .params("type", type)
                .execute(new CacheCallBack<AgreementBean>() {
                    @Override
                    public void onSuccess(Response<AgreementBean> response) {
                        super.onSuccess(response);
                        LoggerUtils.e("我的" + response.body());
                        if (isViewAttached())
                            if (response.body().getCode() == Constants.HTTP_SUCCESS)
                                getView().onAgreementSuccess(response.body());
                            else if (response.body().getCode() == Constants.HTTP_AGAIN_LOGIN)
                                getView().onReLoggedIn(response.body().getMsg());
                            else
                                getView().onError(response.body().getMsg());
                    }
                });
    }
}
